package com.wn.controller;

import org.springframework.core.convert.converter.Converter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Date;

/**
 * @author yellow Docter
 * @date 2022 -07-11
 * @desc
 */
@Controller
public class DataController {

    @ResponseBody
    @RequestMapping("date1")
    public String date1(Date date){

        System.out.println("date = " + date);
        return "success";
    }

    Converter c;

    // @DateTimeFormat 日期格式化 , 可以把前端的指定的字符串转成date类型
    // pattern 自定义字符串格式

    @ResponseBody
    @RequestMapping("date2")
    public String date1(Date date,
            @DateTimeFormat(pattern ="yyyy-MM-dd") Date date2,
            @DateTimeFormat(pattern ="yyyy:MM:dd:HH:mm:ss") Date date3){

        System.out.println("date = " + date);
        System.out.println("date2 = " + date2);
        System.out.println("date3 = " + date3);
        return "success";
    }

}
